//
// Created by void on 24-1-13.
//



#ifndef RECTORHTTPSERVER_BUFF_H
#define RECTORHTTPSERVER_BUFF_H

#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/uio.h>
#include <sys/socket.h>


struct Buffer {
    char* data;
    int capacity;
    int readPos;
    int writePos;
};

struct Buffer* bufferInit(int size);

void bufferDestory(struct Buffer* buf);

void bufferExtendRoom(struct Buffer* buffer, int size);

int bufferWriteableSize(struct Buffer* buffer);

int bufferReadableSize(struct Buffer* buffer);

int bufferAppendData(struct Buffer* buffer, const char* data, int size);

int bufferAppendString(struct Buffer* buffer, const char* data);

int bufferSocketRead(struct Buffer* buffer, int fd);

char *bufferFindCRLF(struct Buffer* buffer);

int bufferSendData(struct Buffer* buffer, int socket);


#endif //RECTORHTTPSERVER_BUFF_H
